package com.krain.ddbb.activity;


import android.app.FragmentTransaction;
import android.content.Intent;
import android.os.Bundle;

import com.krain.ddbb.R;
import com.krain.ddbb.base.BaseActivity;
import com.krain.ddbb.entity.UserAccountBean;
import com.krain.ddbb.entity.UserCardBean;
import com.krain.ddbb.fragment.BindCardFragment_;
import com.krain.ddbb.fragment.UnBindedCardFragment_;

import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.Extra;

/**
 * Created by 胡亚敏 on 2016/3/15 0015.
 */
@EActivity(R.layout.activity_bindcard)
public class BindCardActivity extends BaseActivity {
    UnBindedCardFragment_ unbindCardFragment;
    BindCardFragment_ bindCardFragment;
    @Extra("bind")
    boolean isBind;
    @Extra("userCardBean")
    UserAccountBean cardBean;

    @Override
    protected String getToolbarTitle() {
        return "绑定银行卡";
    }

    public static void jumpTothisActivity(BaseActivity baseActivity,UserAccountBean bean,boolean isBind){
        Intent intent = new Intent(baseActivity,BindCardActivity_.class);
        intent.putExtra("userCardBean",bean);
        intent.putExtra("bind",isBind);
        baseActivity.startActivityForResult(intent,0);
    }

    @AfterViews
    void afterViews() {
        unbindCardFragment = new UnBindedCardFragment_();
        bindCardFragment = new BindCardFragment_();
        Bundle bundle = new Bundle();
        bundle.putParcelable("bean",cardBean);
        bindCardFragment.setArguments(bundle);
        FragmentTransaction transaction = getFragmentManager().beginTransaction();
        if (isBind)
            transaction.replace(R.id.act_bindcard_fl, bindCardFragment);
        else
            transaction.replace(R.id.act_bindcard_fl, unbindCardFragment);
        transaction.commit();
    }


}
